import Vue from 'vue'
import Router from 'vue-router'

import Layout from 'pages/Layout/Layout'
import { routePathData } from 'assets/scripts/common'

const _import = require('./_import_' + process.env.NODE_ENV)
Vue.use(Router)

// 任务构建
const taskflowRouter = [
  {
    path: 'taskflow/list',
    component: _import('Workflow/WorkFlow')
  },
  {
    path: 'taskflow/drawer',
    component: _import('Workflow/WorkFlowDrawer')
  },
  {
    path: 'taskflow/record',
    component: _import('Workflow/BuildRecord')
  },
  {
    path: 'taskflow/set',
    component: _import('Workflow/WorkflowSetting')
  }
]

// 标注管理
const markRouter = [
  {
    path: 'mark/visual',
    component: _import('Mark/Mark')
  },
  {
    path: 'mark/modulemanage',
    component: _import('Mark/ModuleManage')
  },
  {
    path: 'mark/templatemanage',
    component: _import('Mark/TemplateManage')
  },
  {
    path: 'mark/preview',
    component: _import('Mark/Preview/Preview')
  }
]

// 文件管理相关路由
const fileRouter = [
  {
    path: 'file',
    component: _import('File/File')
  }
]

// 业务管理相关路由
const lineRouter = [
  {
    path: 'linemanage/linelist',
    component: _import('Linemanage/LineList')
  },
  {
    path: 'linemanage/linedetail',
    component: _import('Linemanage/LineDetail')
  }
]

let router = new Router({
  routes: [
    {
      path: '/',
      redirect: routePathData.login
    },
    {
      path: routePathData.register,
      component: _import('Login/Register')
    },
    {
      path: routePathData.success,
      component: _import('Login/Success')
    },
    {
      path: routePathData.login,
      component: _import('Login/Login')
    },
    {
      path: routePathData.home,
      component: Layout,
      redirect: routePathData.file,
      children: [
        {
          path: 'userinfo',
          component: _import('Login/UserInfo')
        }
      ]

        .concat(taskflowRouter)
        .concat(fileRouter)
        .concat(markRouter)
        .concat(lineRouter)
    },
    {
      path: '*',
      name: '404',
      component: _import('Common/NoFind')
    }
  ]
})

export default router
